﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Wicresoft.SMS.Data
{
    public class LogService
    {
        private string connectstring;
        public LogService(string cs)
        {
            this.connectstring = cs;
        }

        public void WriteLog(DateTime dt, string product, string type, string msg, string user)
        {
            try
            {
                using (var dbacc = new Entities(connectstring))
                {
                    Log log = new Log();
                    log.LocalTime = dt;
                    log.ServerTime = DateTime.Now;
                    log.Product = product;
                    log.Type = type;
                    log.Message = msg;
                    log.UserInfo = user;
                    dbacc.AddToLog(log);
                    dbacc.SaveChanges();
                }
            }
            catch (Exception)
            {
                
            }           
        }
    }
}
